package com.tuzhi.common.domain;


public class TzCacheBO<T> {
    String key;
    String dataStr;
    Long lastUPdateTimeMillis;

    //备用属性，用于存放用户转换后的Json对象
    T obj;

    public TzCacheBO(String key, String dataStr) {
        this.key = key;
        this.dataStr = dataStr;
        this.lastUPdateTimeMillis = System.currentTimeMillis();
    }

    public TzCacheBO(String key, String dataStr, long lastUPdateTimeMillis) {
        this.key = key;
        this.dataStr = dataStr;
        this.lastUPdateTimeMillis = lastUPdateTimeMillis;
    }

    public TzCacheBO(String key, String dataStr, T obj) {
        this.key = key;
        this.dataStr = dataStr;
        this.obj = obj;
        this.lastUPdateTimeMillis = System.currentTimeMillis();
    }

    /**
     * 可以指定需要缓存的时间，这个时间是经过LdapFindCacheUtil.validTime运算过后的时间，
     * 因为判断是否有效是基于LdapFindCacheUtil.validTime统一运算的。
     * @param key
     * @param dataStr
     * @param obj
     * @param lastUPdateTimeMillis
     */
    public TzCacheBO(String key, String dataStr, T obj, long lastUPdateTimeMillis) {
        this.key = key;
        this.dataStr = dataStr;
        this.obj = obj;
        this.lastUPdateTimeMillis = lastUPdateTimeMillis;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getDataStr() {
        return dataStr;
    }

    public void setDataStr(String dataStr) {
        this.dataStr = dataStr;
    }

    public Long getLastUPdateTimeMillis() {
        return lastUPdateTimeMillis;
    }

    public void setLastUPdateTimeMillis(Long lastUPdateTimeMillis) {
        this.lastUPdateTimeMillis = lastUPdateTimeMillis;
    }

    public T getObj() {
        return obj;
    }

    public void setObj(T obj) {
        this.obj = obj;
    }

    @Override
    public String toString() {
        return "TzCacheBO{" +
                "key='" + key + '\'' +
                ", dataStr='" + dataStr + '\'' +
                ", lastUPdateTimeMillis=" + lastUPdateTimeMillis +
                ", obj=" + obj +
                '}';
    }
}
